from django.conf import settings
from django.utils.translation import get_language
from haystack.query import SearchQuerySet, DEFAULT_OPERATOR

class MiQueryModificada(SearchQuerySet):
    def filter(self, **kwargs):
        if 'content' in kwargs:
            kwd = kwargs.pop('content')
            kwdkey = "name_%s" % str(get_language())
            kwargs[kwdkey] = kwd
        if getattr(settings, 'HAYSTACK_DEFAULT_OPERATOR', DEFAULT_OPERATOR) == 'OR':
           return self.filter_or(**kwargs)
        else:
            return self.filter_and(**kwargs)
